<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .c1 li {
        list-style: none;
        float: left;
        width: 200px;
        height: 240px;
        border: 1px solid pink;
        /* -1px解决边框重合问题 */
        margin-left: -1px;
      }
      .clearfix::after {
        content: "";
        height: 0;
        clear: both;
        display: block;
        visibility: hidden;
      }

      .c2 li {
        /* 父元素有定位属性时用z-index */
        /* position: relative; */
        list-style: none;
        float: left;
        width: 200px;
        height: 240px;
        border: 1px solid gray;
        /* -1px解决边框重合问题 */
        margin-left: -1px;
      }

      .c2 li:hover {
        position: relative;
        /* z-index: 1; */
        border: 1px solid pink;
      }
    </style>
  </head>
  <body>
    <div class="c1 clearfix">
      <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
      </ul>
    </div>
    <br />
    <div class="c2">
      <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
      </ul>
    </div>
  </body>
</html>
